package com.cxx.rabbit.controller;

import com.cxx.rabbit.service.CourseService;
import com.cxx.rabbit.domain.Course;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class CourseController {

    @Autowired
    private CourseService courseService;

    @RequestMapping("/course/list")
    public String listCourses(Model model) {
        final List<Course> courses = courseService.listCourses();
        model.addAttribute("courseList", courses);

        return "list";
    }

}
